using System;
using System.Collections.Generic;
using System.Text;
using IMAPI2;

namespace IMAPIWrapper
{
    public class DiscFormatRawCD
    {
        internal MsftDiscFormat2RawCD internalCD;
        public DiscFormatRawCD()
        {
            internalCD = new MsftDiscFormat2RawCDClass();
        }
        internal DiscFormatRawCD(MsftDiscFormat2RawCD cd)
        {
            internalCD = cd;
        }

        #region IDiscFormat2RawCD Members

        public bool BufferUnderrunFreeDisabled
        {
            get
            {
                return internalCD.BufferUnderrunFreeDisabled;
            }
            set
            {
                internalCD.BufferUnderrunFreeDisabled = value;
            }
        }

        public void CancelWrite()
        {
            internalCD.CancelWrite();
        }

        public string ClientName
        {
            get
            {
                return internalCD.ClientName;
            }
            set
            {
                internalCD.ClientName = value;
            }
        }

        public IMAPI_MEDIA_PHYSICAL_TYPE CurrentPhysicalMediaType
        {
            get { return (IMAPI_MEDIA_PHYSICAL_TYPE) internalCD.CurrentPhysicalMediaType; }
        }

        public bool CurrentRotationTypeIsPureCAV
        {
            get { return internalCD.CurrentRotationTypeIsPureCAV; }
        }

        public int CurrentWriteSpeed
        {
            get { return internalCD.CurrentWriteSpeed; }
        }

        public bool IsCurrentMediaSupported(DiscRecorder Recorder)
        {
            return internalCD.IsCurrentMediaSupported(Recorder.internalRecorder);
        }

        public bool IsRecorderSupported(DiscRecorder Recorder)
        {
            return internalCD.IsRecorderSupported(Recorder.internalRecorder);
        }

        public int LastPossibleStartOfLeadout
        {
            get { return internalCD.LastPossibleStartOfLeadout; }
        }

        public bool MediaHeuristicallyBlank
        {
            get { return internalCD.MediaHeuristicallyBlank; }
        }

        public bool MediaPhysicallyBlank
        {
            get { return internalCD.MediaPhysicallyBlank; }
        }

        public void PrepareMedia()
        {
            internalCD.PrepareMedia();
        }
        public DiscRecorder Recorder
        {
            get
            {
                return new DiscRecorder(internalCD.Recorder);
            }
            set
            {
                internalCD.Recorder = value.internalRecorder;
            }
        }

        public void ReleaseMedia()
        {
            internalCD.ReleaseMedia();
        }

        public bool RequestedRotationTypeIsPureCAV
        {
            get { return internalCD.RequestedRotationTypeIsPureCAV; }
        }

        public IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE RequestedSectorType
        {
            get
            {
                return (IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE) internalCD.RequestedSectorType;
            }
            set
            {
                internalCD.RequestedSectorType = (IMAPI2.IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE)value;
            }
        }

        public int RequestedWriteSpeed
        {
            get { return internalCD.RequestedWriteSpeed; }
        }

        public void SetWriteSpeed(int RequestedSectorsPerSecond, bool RotationTypeIsPureCAV)
        {
            internalCD.SetWriteSpeed(RequestedSectorsPerSecond, RotationTypeIsPureCAV);
        }

        public int StartOfNextSession
        {
            get { return internalCD.StartOfNextSession; }
        }

        public IMAPI_MEDIA_PHYSICAL_TYPE[] SupportedMediaTypes
        {
            get { return (IMAPI_MEDIA_PHYSICAL_TYPE[]) internalCD.SupportedMediaTypes; }
        }

        public uint[] SupportedSectorTypes
        {
            get { return (uint[])internalCD.SupportedSectorTypes; }
        }

        public WriteSpeedDescriptor[] SupportedWriteSpeedDescriptors
        {
            get 
            {
                List<WriteSpeedDescriptor> list = new List<WriteSpeedDescriptor>();
                foreach (MsftWriteSpeedDescriptor descriptor in internalCD.SupportedWriteSpeedDescriptors)
                    list.Add(new WriteSpeedDescriptor(descriptor));
                return list.ToArray();
            }
        }

        public uint[] SupportedWriteSpeeds
        {
            get { return (uint[])internalCD.SupportedWriteSpeeds; }

        }

        public void WriteMedia(IStream data)
        {
            internalCD.WriteMedia(data);
        }

        public void WriteMedia2(IStream data, int streamLeadInSectors)
        {
            internalCD.WriteMedia2(data, streamLeadInSectors);
        }

        #endregion
    }
}
